/**
 * Project  : monkey
 * Author   : Wu Tian Qiang
 * Date     : 2016/10/26 15:41:10
 */
Ext.define('Monkey.view.role.Role', {
    extend: 'Ext.panel.Panel',

    id: 'mk-role',
    controller: 'ctrl-role',
    layout: 'fit',
    tbar: [{
        xtype: 'tbtext',
        html: '角色管理'
    }, '-', {
        icon: 'resources/icons/16/tag_blue_add.png',
        text: '新增',
        handler: 'addRole'
    }, '-', {
        icon: 'resources/icons/16/tag_blue_edit.png',
        text: '修改',
        handler: 'modifyRole'
    }, '-', {
        icon: 'resources/icons/16/tag_blue_delete.png',
        text: '删除',
        handler: 'removeRole'
    }, '-', {
        icon: 'resources/icons/16/eye.png',
        text: '查看已分配的权限',
        handler: 'viewPermission'
    }, '->', {
        xtype: 'textfield',
        reference: 'name',
        emptyText: '输入要查询名称...',
        labelAlign: 'right',
        fieldLabel: '名称'
    }, {
        xtype: 'textfield',
        reference: 'role',
        emptyText: '输入要查询角色标识...',
        labelAlign: 'right',
        fieldLabel: '角色标识',
        labelWidth: 60
    }, {
        iconCls: 'page-find',
        text: '查询',
        handler: 'findRole'
    }, {
        iconCls: 'refresh',
        text: '重置',
        handler: 'reloadRole'
    }],
    initComponent: function () {
        var store = Ext.create('Monkey.store.role.Role');
        this.items = [{
            id: 'roleGrid',
            xtype: 'grid',
            reference: 'roleGrid',
            selType: 'checkboxmodel',
            store: store,
            listeners: {
                rowdblclick: 'rowdblclick'
            },
            bbar: {
                xtype: 'pagingtoolbar',
                pageSize: 10,
                store: store,
                displayInfo: true,
                plugins: new Ext.ux.ProgressBarPager()
            },
            columns: [{
                width: 30,
                xtype: 'rownumberer'
            }, {
                text: 'id',
                dataIndex: 'id',
                hidden: true,
                width: 100
            }, {
                text: '&nbsp;',
                width: 80,
                xtype: 'widgetcolumn',
                widget: {
                    xtype: 'button',
                    icon: 'resources/icons/16/tag_purple.png',
                    text: '授权',
                    handler: 'showGrantPermissionWin'
                }
            }, {
                text: '名称',
                dataIndex: 'name',
                width: 150
            }, {
                text: '角色标识',
                dataIndex: 'role',
                width: 150
            }, {
                text: '描述',
                dataIndex: 'description',
                flex: 1
            }]
        }];
        this.callParent();
    }
});